package server

import (
	"gitee.com/enjoy_5/coupons-rpc/internal/models"
	coupons "gitee.com/enjoy_5/coupons-rpc/proto/coupon"
)

func rulesModelList(rule []models.Rule) (info []*coupons.RulesInfo) {
	for _, v := range rule {
		info = append(info, &coupons.RulesInfo{
			Id:        int64(v.ID),
			ImageUrl:  v.ImageUrl,
			Title:     v.Title,
			Moment:    v.Moment,
			Introduce: v.Introduce,
			Price:     float32(v.Price),
		})
	}
	return info
}

func TakeList() []*coupons.RulesInfo {
	m := new(models.Rule)
	RuleList, err := m.RuleList()
	if err != nil {
		return nil
	}
	return rulesModelList(RuleList)
}

func TakeMemberList() []models.Rule {
	m := new(models.Rule)
	RuleList, err := m.RuleList()
	if err != nil {
		return nil
	}
	return RuleList
}
